
# 编码解码
import json

class Request:
    def __init__(self, request):
        self.req = request
        self.method = request.method
        self.path = request.path
        self.body = request.body
        self.headers = request.headers
        self.params = request.GET
        self.cookies = request.COOKIES
        self.files = request.FILES
        
    # get json value in body
    def get(self, key):
        try:
            self.json = json.loads(self.body.decode())
        except:
            self.json = {}
        return self.json.get(key)

